unit MainFrm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, 
  Controls, Forms, Dialogs,StdCtrls;

type

  TMainForm = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  TShowFormProc= procedure (parent:TMainForm); stdcall;

var
  MainForm: TMainForm;

implementation


{$R *.DFM}

procedure TMainForm.Button1Click(Sender: TObject);
var h:THandle;
       ShowFormProc:TShowFormProc;
begin
   h:=LoadLibrary('FRMLIB2.DLL');

  if h=0 then begin
     ShowMessage('Can not load FRMLIB2.DLL');
     exit;
  end;

  ShowFormProc:=GetProcAddress(h,'ShowSubForm');

  if @ShowFormProc=nil then begin
     ShowMessage('Function ShowSubForm not found in DLL');
     exit;
  end;

  ShowFormProc(self);

  FreeLibrary(h);
end;

end.
